<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h1>我是公共区域</h1>
    <router-view></router-view>
  </div>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
  <script>
    // home news about
    const Home = {
      template:`
        <div>
          <h1>home页</h1>
        </div>
      `
    }
    const News = {
      template:`
        <div>
          <h1>新闻页</h1>
        </div>
      `
    }
    const About = {
      template:`
        <div>
          <h1>关于我们</h1>
        </div>
      `
    }
    // 定义路由对象
    const router = new VueRouter({
      routes: [ // 定义路由 规则 有哪些路由，这个路由对于的组件是什么
        {
          path:"/home",
          component: Home
        },
        {
          path:"/news",
          component: News
        },
        {
          path: '/about',
          component: About
        }
      ]
    })
    const vm = new Vue({
      el:"#app",
      router
    })
  </script>
</body>
</html>
